# 需要填写你的 Access Key 和 Secret Key
from qiniu import Auth, put_data

access_key = 'A5SK6yGdIfk6mcUL6KrhWOonBHnFNcfA5ccSt1e-'
secret_key = 'eVW3siHLhFIdfsUqjmynnwG-1qzK-WYq0xaDLSSo'
# 构建鉴权对象
q = Auth(access_key, secret_key)
# 要上传的空间
bucket_name = 'yizhangbang'
domain_prefix = 'http://cdn.qhdyzb.cn/'


def qiniu_upload_file(source_file, save_file_name):
    # 生成上传 Token，可以指定过期时间等
    token = q.upload_token(bucket_name, save_file_name)
    ret, info = put_data(token, save_file_name, source_file)
    print(type(info.status_code), info)
    if info.status_code == 200:
        return domain_prefix + save_file_name
    return None
